home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / OPTIMIZE / STRINGS.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  12.0 KB  |  379 lines

  1. VERSION 5.00
  2. Begin VB.Form Strings 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Strings & Files"
  5.    ClientHeight    =   4650
  6.    ClientLeft      =   1575
  7.    ClientTop       =   2100
  8.    ClientWidth     =   7215
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    MinButton       =   0   'False
  22.    PaletteMode     =   1  'UseZOrder
  23.    ScaleHeight     =   4650
  24.    ScaleWidth      =   7215
  25.    ShowInTaskbar   =   0   'False
  26.    Tag             =   "Real"
  27.    Begin VB.CommandButton cmdString 
  28.       Caption         =   "Build outside Loop"
  29.       BeginProperty Font 
  30.          Name            =   "MS Sans Serif"
  31.          Size            =   8.25
  32.          Charset         =   0
  33.          Weight          =   400
  34.          Underline       =   0   'False
  35.          Italic          =   0   'False
  36.          Strikethrough   =   0   'False
  37.       EndProperty
  38.       Height          =   450
  39.       Index           =   1
  40.       Left            =   120
  41.       TabIndex        =   1
  42.       Top             =   1320
  43.       Width           =   1900
  44.    End
  45.    Begin VB.TextBox txtCount2 
  46.       Height          =   280
  47.       Left            =   5700
  48.       TabIndex        =   5
  49.       Text            =   "1000"
  50.       Top             =   2520
  51.       Width           =   1400
  52.    End
  53.    Begin VB.CommandButton cmdFiles 
  54.       Caption         =   "Binary"
  55.       BeginProperty Font 
  56.          Name            =   "MS Sans Serif"
  57.          Size            =   8.25
  58.          Charset         =   0
  59.          Weight          =   400
  60.          Underline       =   0   'False
  61.          Italic          =   0   'False
  62.          Strikethrough   =   0   'False
  63.       EndProperty
  64.       Height          =   450
  65.       Index           =   1
  66.       Left            =   120
  67.       TabIndex        =   3
  68.       Top             =   3840
  69.       Width           =   1900
  70.    End
  71.    Begin VB.CommandButton cmdFiles 
  72.       Caption         =   "Random"
  73.       BeginProperty Font 
  74.          Name            =   "MS Sans Serif"
  75.          Size            =   8.25
  76.          Charset         =   0
  77.          Weight          =   400
  78.          Underline       =   0   'False
  79.          Italic          =   0   'False
  80.          Strikethrough   =   0   'False
  81.       EndProperty
  82.       Height          =   450
  83.       Index           =   0
  84.       Left            =   120
  85.       TabIndex        =   2
  86.       Top             =   3120
  87.       Width           =   1900
  88.    End
  89.    Begin VB.CommandButton cmdString 
  90.       Caption         =   "Build in Loop"
  91.       Default         =   -1  'True
  92.       BeginProperty Font 
  93.          Name            =   "MS Sans Serif"
  94.          Size            =   8.25
  95.          Charset         =   0
  96.          Weight          =   400
  97.          Underline       =   0   'False
  98.          Italic          =   0   'False
  99.          Strikethrough   =   0   'False
  100.       EndProperty
  101.       Height          =   450
  102.       Index           =   0
  103.       Left            =   120
  104.       TabIndex        =   0
  105.       Top             =   660
  106.       Width           =   1900
  107.    End
  108.    Begin VB.TextBox txtCounter 
  109.       Height          =   280
  110.       Left            =   5700
  111.       TabIndex        =   4
  112.       Text            =   "txtCounter"
  113.       Top             =   120
  114.       Width           =   1400
  115.    End
  116.    Begin VB.Label lblFiles 
  117.       Appearance      =   0  'Flat
  118.       BackColor       =   &H80000005&
  119.       BackStyle       =   0  'Transparent
  120.       Caption         =   "00.00 secs"
  121.       BeginProperty Font 
  122.          Name            =   "MS Sans Serif"
  123.          Size            =   9.75
  124.          Charset         =   0
  125.          Weight          =   700
  126.          Underline       =   0   'False
  127.          Italic          =   0   'False
  128.          Strikethrough   =   0   'False
  129.       EndProperty
  130.       ForeColor       =   &H00800000&
  131.       Height          =   280
  132.       Index           =   1
  133.       Left            =   5700
  134.       TabIndex        =   8
  135.       Top             =   3840
  136.       Width           =   1400
  137.    End
  138.    Begin VB.Label lblFiles 
  139.       Appearance      =   0  'Flat
  140.       BackColor       =   &H80000005&
  141.       BackStyle       =   0  'Transparent
  142.       Caption         =   "00.00 secs"
  143.       BeginProperty Font 
  144.          Name            =   "MS Sans Serif"
  145.          Size            =   9.75
  146.          Charset         =   0
  147.          Weight          =   700
  148.          Underline       =   0   'False
  149.          Italic          =   0   'False
  150.          Strikethrough   =   0   'False
  151.       EndProperty
  152.       ForeColor       =   &H00800000&
  153.       Height          =   280
  154.       Index           =   0
  155.       Left            =   5700
  156.       TabIndex        =   10
  157.       Top             =   3120
  158.       Width           =   1400
  159.    End
  160.    Begin VB.Label Label2 
  161.       Appearance      =   0  'Flat
  162.       BackColor       =   &H80000005&
  163.       BackStyle       =   0  'Transparent
  164.       Caption         =   "Read && Write records using Binary I/O"
  165.       ForeColor       =   &H80000008&
  166.       Height          =   450
  167.       Left            =   2150
  168.       TabIndex        =   13
  169.       Top             =   3840
  170.       Width           =   3100
  171.    End
  172.    Begin VB.Label Label1 
  173.       Appearance      =   0  'Flat
  174.       BackColor       =   &H80000005&
  175.       BackStyle       =   0  'Transparent
  176.       Caption         =   "Read && Write records using Random access"
  177.       ForeColor       =   &H80000008&
  178.       Height          =   450
  179.       Index           =   4
  180.       Left            =   2150
  181.       TabIndex        =   15
  182.       Top             =   3120
  183.       Width           =   3100
  184.    End
  185.    Begin VB.Label lblTitle 
  186.       Appearance      =   0  'Flat
  187.       AutoSize        =   -1  'True
  188.       BackColor       =   &H80000005&
  189.       BackStyle       =   0  'Transparent
  190.       Caption         =   "File I/O"
  191.       BeginProperty Font 
  192.          Name            =   "MS Sans Serif"
  193.          Size            =   12
  194.          Charset         =   0
  195.          Weight          =   700
  196.          Underline       =   0   'False
  197.          Italic          =   0   'False
  198.          Strikethrough   =   0   'False
  199.       EndProperty
  200.       ForeColor       =   &H00800000&
  201.       Height          =   300
  202.       Index           =   2
  203.       Left            =   120
  204.       TabIndex        =   14
  205.       Top             =   2400
  206.       Width           =   1875
  207.    End
  208.    Begin VB.Line Line2 
  209.       BorderColor     =   &H00808080&
  210.       X1              =   0
  211.       X2              =   7335
  212.       Y1              =   2100
  213.       Y2              =   2100
  214.    End
  215.    Begin VB.Label Label1 
  216.       Appearance      =   0  'Flat
  217.       BackColor       =   &H80000005&
  218.       BackStyle       =   0  'Transparent
  219.       Caption         =   "Copy the strings to a temp Variable, then copy temp to new Variable"
  220.       ForeColor       =   &H80000008&
  221.       Height          =   450
  222.       Index           =   3
  223.       Left            =   2145
  224.       TabIndex        =   12
  225.       Top             =   1320
  226.       Width           =   3105
  227.    End
  228.    Begin VB.Label Label1 
  229.       Appearance      =   0  'Flat
  230.       BackColor       =   &H80000005&
  231.       BackStyle       =   0  'Transparent
  232.       Caption         =   "Explicitly copy strings to the new Variable"
  233.       ForeColor       =   &H80000008&
  234.       Height          =   450
  235.       Index           =   2
  236.       Left            =   2150
  237.       TabIndex        =   11
  238.       Top             =   660
  239.       Width           =   3100
  240.    End
  241.    Begin VB.Label lblString 
  242.       Appearance      =   0  'Flat
  243.       BackColor       =   &H80000005&
  244.       BackStyle       =   0  'Transparent
  245.       Caption         =   "00.00 secs"
  246.       BeginProperty Font 
  247.          Name            =   "MS Sans Serif"
  248.          Size            =   9.75
  249.          Charset         =   0
  250.          Weight          =   700
  251.          Underline       =   0   'False
  252.          Italic          =   0   'False
  253.          Strikethrough   =   0   'False
  254.       EndProperty
  255.       ForeColor       =   &H00800000&
  256.       Height          =   280
  257.       Index           =   0
  258.       Left            =   5700
  259.       TabIndex        =   9
  260.       Top             =   660
  261.       Width           =   1400
  262.    End
  263.    Begin VB.Label lblString 
  264.       Appearance      =   0  'Flat
  265.       BackColor       =   &H80000005&
  266.       BackStyle       =   0  'Transparent
  267.       Caption         =   "00.00 secs"
  268.       BeginProperty Font 
  269.          Name            =   "MS Sans Serif"
  270.          Size            =   9.75
  271.          Charset         =   0
  272.          Weight          =   700
  273.          Underline       =   0   'False
  274.          Italic          =   0   'False
  275.          Strikethrough   =   0   'False
  276.       EndProperty
  277.       ForeColor       =   &H00800000&
  278.       Height          =   280
  279.       Index           =   1
  280.       Left            =   5700
  281.       TabIndex        =   7
  282.       Top             =   1320
  283.       Width           =   1400
  284.    End
  285.    Begin VB.Label lblTitle 
  286.       Appearance      =   0  'Flat
  287.       AutoSize        =   -1  'True
  288.       BackColor       =   &H80000005&
  289.       BackStyle       =   0  'Transparent
  290.       Caption         =   "Strings"
  291.       BeginProperty Font 
  292.          Name            =   "MS Sans Serif"
  293.          Size            =   12
  294.          Charset         =   0
  295.          Weight          =   700
  296.          Underline       =   0   'False
  297.          Italic          =   0   'False
  298.          Strikethrough   =   0   'False
  299.       EndProperty
  300.       ForeColor       =   &H00800000&
  301.       Height          =   300
  302.       Index           =   1
  303.       Left            =   120
  304.       TabIndex        =   6
  305.       Top             =   60
  306.       Width           =   1875
  307.    End
  308.    Begin VB.Line Line1 
  309.       BorderColor     =   &H00FFFFFF&
  310.       BorderWidth     =   2
  311.       Index           =   0
  312.       X1              =   0
  313.       X2              =   7335
  314.       Y1              =   2115
  315.       Y2              =   2115
  316.    End
  317. Attribute VB_Name = "Strings"
  318. Attribute VB_GlobalNameSpace = False
  319. Attribute VB_Creatable = False
  320. Attribute VB_TemplateDerived = False
  321. Attribute VB_PredeclaredId = True
  322. Attribute VB_Exposed = False
  323. Private Sub cmdFiles_Click(Index As Integer)
  324. 'Use Binary instead of Random File I/O"
  325.     On Error Resume Next
  326.     Dim allrecs() As BookAuthor
  327.     ReDim allrecs(txtCount2)
  328.     Me.MousePointer = 11
  329.     For x = 1 To txtCount2
  330.         allrecs(x).ID = x
  331.         allrecs(x).Name = "John Doe - Generic Person"
  332.     Next x
  333.     Kill App.Path & "\" & "files.out"
  334.     If Index = 0 Then
  335.         Open App.Path & "\" & "files.out" For Random As #1
  336.     Else
  337.         Open App.Path & "\" & "files.out" For Binary As #1
  338.     End If
  339.     start# = Timer
  340.     For x = 1 To txtCount2
  341.        Put #1, , allrecs(x)
  342.     Next x
  343.     Seek #1, 1
  344.     For x = 1 To txtCount2
  345.         Get #1, , allrecs(x)
  346.     Next x
  347.     Finish# = Timer
  348.     lblFiles(Index) = Format(Finish# - start#, "##.##") & " secs."
  349.     Close #1
  350.     Me.MousePointer = 0
  351. End Sub
  352. Private Sub cmdString_Click(Index As Integer)
  353.     strfirst$ = "Really long String. "
  354.     strsecond$ = "Next really long string. "
  355.     strthird$ = "I mean this is going to be a really long one!"
  356.     MousePointer = 11
  357.     If Index = 0 Then
  358.         start# = Timer
  359.         For x = 1 To txtCounter
  360.             result$ = strfirst$ & strsecond$ & strthird$
  361.         Next x
  362.         Finish# = Timer
  363.     Else
  364.         Temp$ = strfirst$ & strsecond$ & strthird$
  365.         start# = Timer
  366.         For x = 1 To txtCounter
  367.             result$ = Temp$
  368.         Next x
  369.         Finish# = Timer
  370.     End If
  371.     lblString(Index) = Format$(Finish# - start#, "##.##") & " secs."
  372.     MousePointer = 0
  373. End Sub
  374. Private Sub Form_Load()
  375.   PosForm Me
  376.   txtCounter = 10000
  377.   txtCount2 = 1000
  378. End Sub
  379.